/**
 * @date 2006-7-26 17:16:35
 *
 */
package org.nanhill.moo.service.util;

import java.util.HashMap;
import java.util.Map;

/**
 * @author alin [xalinx at gmail dot com]
 * 
 */
public class TagHotProcessor {
	private static final Map<Long, Integer> userHotMap = new HashMap<Long, Integer>();

	private static final Map<Long, Integer> favorHotMap = new HashMap<Long, Integer>();

	private TagHotProcessor() {
	}

	public static void addUserHot(long userId, int addHot) {
		Integer hotWrap = userHotMap.get(userId);
		userHotMap.put(userId, (null == hotWrap ? 0 : hotWrap + addHot));
	}

	public static void addFavorHot(long favorId, int addHot) {
		Integer hotWrap = userHotMap.get(favorId);
		favorHotMap.put(favorId, (null == hotWrap ? 0 : hotWrap + addHot));
	}

	public static long[][] exportAndClearUserHotIncrease() {
		long[][] userHotArray = new long[userHotMap.size()][2];
		int i = 0;
		for (long userId : userHotMap.keySet()) {
			userHotArray[i][0] = userId;
			userHotArray[i][1] = userHotMap.get(userId);
			i++;
		}
		userHotMap.clear();
		return userHotArray;
	}

	public static long[][] exportFavorHotIncrease() {
		long[][] favorHotArray = new long[favorHotMap.size()][2];
		int i = 0;
		for (long favorId : favorHotMap.keySet()) {
			favorHotArray[i][0] = favorId;
			favorHotArray[i][1] = favorHotMap.get(favorId);
			i++;
		}
		favorHotMap.clear();
		return favorHotArray;
	}

}
